#pragma once
#include <iostream>
#include <memory>

class Protocol
{
public:
    Protocol() : _left_num(0), _right_num(0), _opr('+')
    {
    }

    Protocol(int left_num, int right_num, char opr) : _left_num(left_num), _right_num(right_num), _opr(opr)
    {
    }

    ~Protocol()
    {
    }

    void Print()
    {
        std::cout << "left_num = " << _left_num << std::endl
                  << "right_num = " << _right_num << std::endl
                  << "opr : " << _opr << std::endl;
    }

    int Result()
    {
        switch (_opr)
        {
        case '+':
            return _left_num + _right_num;
        case '-':
            return _left_num - _right_num;
        case '*':
            return _left_num * _right_num;
        case '/':
            return _left_num / _right_num;
        default:
            return 0;
        }
    }

    void Inc()
    {
        _left_num++;
        _right_num++;
    }
private:
    int _left_num;
    int _right_num;
    char _opr;
};

class Result
{
public:
    Result() : _result(0), _code(0)
    {
    }

    Result(int result, int code) : _result(result), _code(code)
    {
    }

    void Print()
    {
        std::cout << "result = " << _result << std::endl;
    }

private:
    int _result;
    int _code;
};

class Factory
{
public:
    std::shared_ptr<Protocol> BuildRequest()
    {
        std::shared_ptr<Protocol> req = std::make_shared<Protocol>();
        return req;
    }

    std::shared_ptr<Protocol> BuildRequest(int a, int b, char opr)
    {
        std::shared_ptr<Protocol> req = std::make_shared<Protocol>(a, b, opr);
        return req;
    }

    std::shared_ptr<Result> BuildResult()
    {
        std::shared_ptr<Result> re = std::make_shared<Result>();
        return re;
    }

    std::shared_ptr<Result> BuildResult(int result, int code)
    {
        std::shared_ptr<Result> re = std::make_shared<Result>(result, code);
        return re;
    }
};